package com.d3works.apps.sale.service.configurator;

import com.d3works.apps.sale.db.ConfiguratorCreator;
import com.d3works.apps.sale.db.ConfiguratorFormula;
import com.d3works.exception.D3worksException;
import com.d3works.script.ScriptBindings;

public interface ConfiguratorCreatorService {

  /**
   * Add default view attrs for configurator attributes
   *
   * @param creator
   * @return
   */
  void updateAttributes(ConfiguratorCreator creator);

  /**
   * Add the {@link ConfiguratorFormula#metaField} that need to be shown in configurator in the
   * {@link ConfiguratorCreator#indicators} many-to-one.
   *
   * @param creator
   */
  void updateIndicators(ConfiguratorCreator creator) throws D3worksException;

  /**
   * Get the testing values in {@link ConfiguratorCreator#attributes}
   *
   * @param creator
   * @return
   * @throws D3worksException
   */
  ScriptBindings getTestingValues(ConfiguratorCreator creator) throws D3worksException;

  /**
   * Compute the correct domain to filter creator that are not authorized for the current user.
   *
   * @return the domain
   */
  String getConfiguratorCreatorDomain();

  /**
   * Initialize configurator creator.
   *
   * @param creator
   */
  void init(ConfiguratorCreator creator);

  /**
   * Add required fields of Product to the formula list
   *
   * @param creator
   */
  void addRequiredFormulas(ConfiguratorCreator creator);

  /**
   * Activates the creator and saves it.
   *
   * @param creator
   */
  void activate(ConfiguratorCreator creator);

  /**
   * Method for a quick fix on a constraint issue
   *
   * @param creator
   */
  void removeTemporalAttributesAndIndicators(ConfiguratorCreator creator);
}
